package cn.iocoder.yudao.module.api.trade.order.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 站内信模板枚举类
 *
 * @author HUIHUI
 * @author 山野羡民
 */
@Getter
@AllArgsConstructor
public enum TradeNotifySceneEnum implements ArrayValuable<Integer> {

    ORDER_DELIVERY(1, "trade_order_delivery", "卖家已发货"),
    ORDER_PAY(2, "trade_order_pay", "买家已付款"),
    ORDER_AFTER_SALE_CREATE(3, "trade_after_sale_create", "买家申请退款"),
    ORDER_AFTER_SALE_AGREE(4, "trade_after_sale_agree", "卖家同意退款"),
    ORDER_AFTER_SALE_DISAGREE(5, "trade_after_sale_disagree", "卖家拒绝退款"),
    ORDER_AFTER_SALE_REFUND(6, "trade_after_sale_refund", "等待平台退款"),
    ORDER_AFTER_SALE_CANCEL(7, "trade_after_sale_cancel", "买家取消退款"),
    ORDER_AFTER_SALE_BUYER_DELIVERY(20, "trade_after_sale_buyer_delivery", "买家寄回退款货物"),
    ORDER_AFTER_SALE_SELLER_RECEIVE(21, "trade_after_sale_seller_receive", "卖家收到退款货物"),
    ORDER_AFTER_SALE_SELLER_REFUSE(22, "trade_after_sale_seller_refuse", "卖家拒收退款货物"),
    ;

    public static final Integer[] ARRAYS = Arrays.stream(values()).map(TradeNotifySceneEnum::getScene).toArray(Integer[]::new);

    /**
     * 场景编号
     */
    private final Integer scene;
    /**
     * 模版编码
     */
    @EnumValue
    private final String templateCode;
    /**
     * 描述
     */
    private final String description;

    @Override
    public Integer[] array() {
        return ARRAYS;
    }

    public static TradeNotifySceneEnum getCodeByScene(Integer scene) {
        return ArrayUtil.firstMatch(sceneEnum -> sceneEnum.getScene().equals(scene),
                values());
    }

}
